/*
 * This file Copyright (c) 2015. Walle.
 * (http://www.wallellen.com). All rights reserved.
 *
 *
 * This file is dual-licensed under both the
 * Walle Agreement (WA) and the GNU General Public License.
 * You may elect to use one or the other of these licenses.
 *
 * This file is distributed in the hope that it will be
 * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
 * Redistribution, except as permitted by whichever of the GPL
 * or WA you select, is prohibited.
 *
 * 1. For the GPL license (GPL), you can redistribute and/or
 * modify this file under the terms of the GNU General
 * Public License, Version 3, as published by the Free Software
 * Foundation.  You should have received a copy of the GNU
 * General Public License, Version 3 along with this program;
 * if not, write to the Free Software Foundation, Inc., 51
 * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * 2. For the Walle Agreement (WA), this file
 * and the accompanying materials are made available under the
 * terms of the WA which accompanies this distribution, and
 * is available at http://www.wallellen.com/agreement.html
 *
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
 */

package com.wallellen.knowledge.doc.server;

import com.wallellen.core.auth.domain.LoginUser;
import com.wallellen.core.sql.query.DataQuery;
import com.wallellen.knowledge.doc.domain.Doc;
import com.wallellen.knowledge.doc.domain.DocText;
import com.wallellen.knowledge.doc.domain.ex.DocEntire;
import com.wallellen.knowledge.doc.exception.CanNoDeleteException;
import com.wallellen.knowledge.doc.exception.CanNoReadException;
import com.wallellen.knowledge.doc.exception.CanNoWriteException;
import com.wallellen.knowledge.doc.exception.DocNoExistException;

import java.util.List;


/**
 * 文档管理
 *
 * @author <a href="mailto:wallellen@hotmail.com">WALLE</a>
 */
public interface DocManagerInter {

    /**
     * 修改文档(不做权限控制)
     *
     * @param entity   标题、发布时间、内容类型是必填 texts中的TEXT1中存放超文本内容
     * @param editNote 修改时的注释
     * @param user     操作用户
     * @return
     */
    public DocEntire editDoc(DocEntire entity, String editNote, LoginUser user);

    /**
     * 带权限的修改实体
     *
     * @param entity   标题、发布时间、内容类型是必填 texts中的TEXT1中存放超文本内容
     * @param editNote 修改备注(记录为啥修改)
     * @param user
     * @return
     * @throws CanNoWriteException
     */
    public DocEntire editDocByUser(DocEntire entity, String editNote, LoginUser user) throws CanNoWriteException;

    /**
     * 删除文档(带权限)
     *
     * @param entity
     */
    public void deleteDoc(String entity, LoginUser user) throws CanNoDeleteException;

    /**
     * 删除文档（不带权限删除）
     *
     * @param entity
     */
    public void deleteDocNoPop(String entity, LoginUser user) throws CanNoDeleteException;

    /**
     * 创建文档
     *
     * @param entity      标题、发布时间、内容类型是必填 texts中的TEXT1中存放超文本内容
     * @param currentUser
     * @return
     */
    public DocEntire createDoc(DocEntire entity, LoginUser currentUser);


    /**
     * 知识基本查询
     *
     * @param query 传入的查询条件封装
     * @return
     */
    public DataQuery createSimpleDocQuery(DataQuery query);

    /**
     * 获取文档数据 判断权限
     *
     * @param id
     * @param user 阅读用户
     * @return
     */
    public DocEntire getDoc(String docid, LoginUser user) throws CanNoReadException, DocNoExistException;

    /**
     * 获取文档数据
     *
     * @param id
     * @return
     */
    public Doc getDocOnlyBean(String id);

    /**
     * 获取文档数据(不判断权限)
     *
     * @param id
     * @return
     */
    @Deprecated
    public DocEntire getDoc(String id);

    /**
     * 创建一个基本查询用来查询当前分类实体
     *
     * @param query 传入的查询条件封装
     * @return
     */
    public DataQuery createSimpleTypeQuery(DataQuery query);

    /**
     * 更新文档的分类（唯一分类）将会清空doc的其它分类
     *
     * @param docid
     * @param typeId
     */
    public void updateDocTypeOnlyOne(String docid, String typeId);

    /**
     * 获得文档的版本信息
     *
     * @param docId
     * @return ID, ETIME, CUSERNAME, DOCID, PCONTENT
     */
    public List<DocText> getDocVersions(String docId);

    /**
     * 获得文档版本信息
     *
     * @param textId
     * @param currentUser
     * @return
     */
    public DocEntire getDocVersion(String textId, LoginUser currentUser);

    /**
     * 删除附件 void
     */
    public void delImg(String imgid);


    /**
     * 获得所有不带分类权限的知识
     *
     * @param query
     * @return
     */
    public DataQuery createAllPubDocQuery(DataQuery query);


}